﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Design;

namespace SimpleSamplesXNA
{
    //plays a video as a background
    class VideoBackGround
    {
        Video myVideoFile;
        VideoPlayer videoPlayer = new VideoPlayer();
        bool Loop;
        bool IsPlaying = false;
        public Rectangle rect;

        public VideoBackGround(Video movie, bool loop)
        {
            myVideoFile = movie;
            Loop = loop;
        }

        public void play()
        {
            videoPlayer.Play(myVideoFile);
            videoPlayer.IsLooped = Loop;
            videoPlayer.IsMuted = true;
        }

        public void stop()
        {
            videoPlayer.Stop();
        }

        public void setLoop(bool lp)
        {
            Loop = lp;
        }

        public bool isPlaying()
        {
            return IsPlaying;
        }

        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (videoPlayer.State == MediaState.Playing)
            {
                IsPlaying = true;
                spriteBatch.Draw(videoPlayer.GetTexture(), rect, Color.White);
            }
            else
                IsPlaying = false;
        }



    }
}
